import 'mpc_plugin_platform_interface.dart';

class MpcPlugin {
  static MpcPlugin? _instance;

  MpcPlugin._internal();

  factory MpcPlugin() {
    _instance ??= MpcPlugin._internal();
    return _instance!;
  }

  Future<Map<String, dynamic>?> getPlatformVersion() {
    return MpcPluginPlatform.instance.getPlatformVersion();
  }

  Future<Map<String, dynamic>?> getLibVersion() {
    return MpcPluginPlatform.instance.getLibVersion();
  }

  Future<Map<String, dynamic>?> forgingMPC(String salt, String path) {
    return MpcPluginPlatform.instance.forgingMPC(salt, path);
  }

  Future<Map<String, dynamic>?> useMnemonicForgingMPC(
      String mne, String salt, String path) {
    return MpcPluginPlatform.instance.useMnemonicForgingMPC(mne, salt, path);
  }

  Future<Map<String, dynamic>?> verifyMPCFragment(String frag) {
    return MpcPluginPlatform.instance.verifyMPCFragment(frag);
  }

  Future<Map<String, dynamic>?> recoverMPCFragment(String frag1, String frag2) {
    return MpcPluginPlatform.instance.recoverMPCFragment(frag1, frag2);
  }

  Future<Map<String, dynamic>?> mpcFragmentGetPublicKey(String frag) {
    return MpcPluginPlatform.instance.mpcFragmentGetPublicKey(frag);
  }

  Future<Map<String, dynamic>?> mpcEscape(
      String frag1, String frag2, String salt) {
    print('flutter-mpcEscape frag1: ${frag1}');
    print('flutter-mpcEscape frag2: ${frag2}');
    print('flutter-mpcEscape salt: ${salt}');
    return MpcPluginPlatform.instance.mpcEscape(frag1, frag2, salt);
  }

  Future<Map<String, dynamic>?> signTx(
      String tx, String mpcA, String mpcB, String salt) {
    return MpcPluginPlatform.instance.signTx(tx, mpcA, mpcB, salt);
  }

  Future<int> getVersionFromFrag(String frag) {
   return MpcPluginPlatform.instance.getVersionFromFrag(frag);
  }


  Future<Map<String, dynamic>?> getAddress(String frag,String chainId){
    return MpcPluginPlatform.instance.getAddress(frag,chainId);
  }

  Future<Map<String, dynamic>?> upgradeMPC(String frag1,String frag2,String salt){
    return MpcPluginPlatform.instance.upgradeMPC(frag1,frag2,salt);
  }

  Future<Map<String, dynamic>?> solSignTx(
      String tx, String mpcA, String mpcB, String salt) {
    return MpcPluginPlatform.instance.solSignTx(tx, mpcA, mpcB, salt);
  }
}
